import torch

from icefall.char_graph_compiler import CharCtcTrainingGraphCompiler
from icefall.lexicon import Lexicon


def init_graph_compiler(lang_dir, device: torch.device):
    lexicon = Lexicon(lang_dir)
    graph_compiler = CharCtcTrainingGraphCompiler(
        lexicon=lexicon,
        device=device,
    )
    return graph_compiler, lexicon


if __name__ == "__main__":
    a = init_graph_compiler("./data/lang_char", torch.device("cpu"))
    print(a.token_table)

